import ColorStr from '@/ColorStr';
import PlayerUtil from '@/PlayerUtil';
import TipFrameUtil from '@/TipFrameUtil';
import UnitStateUtil from '@/UnitStateUtil';
import TalentBase from 'code/Scripts/Abilities/base/TalentBase';
const desc = `击杀敌人时获得额外金币，为敌人生命上限的${ColorSafe}3%|r。觉醒效果：效果提升到${ColorSafe}5%|r`;
const art = 'ReplaceableTextures\\CommandButtons\\BTNPillage.blp';
const name = '炼金术';
const config: TalentConfigModel = {
    id: 'talent_t_TalentAlchemy',
    name,
    desc,
    art,
    buffType: {
        id: 'buff_t_TalentAlchemy',
        art,
        name,
        ubertip: desc,
    },
    buffTypePlus: {
        id: 'buff_t_TalentAlchemy_plus',
        art,
        name: '炼金术[觉醒]',
        ubertip: `击杀敌人时获得额外金币，为敌人生命上限的${ColorSafe}5%|r`,
    },
};
export default class TalentAlchemy extends TalentBase {
    static instance: TalentAlchemy;
    constructor(p?: TalentConfigModel) {
        super(p);
        TalentAlchemy.instance = this;
        this.setTalentConfig(config);
        EventManager.单位死亡(this.onKillEnemy);
    }
    onKillEnemy(d: DamageEventData) {
        let { unEffect, plus } = TalentAlchemy.instance.talentUnEffect(d.source);
        if (unEffect) return;
        let gold = UnitStateUtil.getMaxLife(d.target) * (plus ? 0.05 : 0.03);
        PlayerUtil.addGoldState(GetOwningPlayer(d.source), gold);
        TipFrameUtil.showIconTextOnUnit('UI\\Feedback\\Resources\\ResourceGold.blp', `${ColorStr.gold}+ ${gold}`, d.target, 0.7, 0.113);
        // PlaySound('');
    }
}
